cmake_minimum_required(VERSION 3.0.2)
project(imu_odom_fusion)

#SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
SET(CMAKE_BUILD_TYPE "Debug")
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
add_compile_options(-std=c++14 -g) # for std::make_unique

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  nav_msgs
  message_generation
)

find_package(OpenCV 3.2)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 3.2 not found.")
   endif()

find_package(Eigen3 3.1.0 REQUIRED)
find_package(Pangolin REQUIRED)

## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package(
  INCLUDE_DIRS include
#  LIBRARIES imu_gnss_fusion
  CATKIN_DEPENDS roscpp nav_msgs
  DEPENDS system_lib
  CATKIN_DEPENDS message_runtime
)

include_directories(
  ${catkin_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIR}
  ${Pangolin_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}
  ${PROJECT_SOURCE_DIR}/include
  ${PROJECT_SOURCE_DIR}/include/Filter
  ${PROJECT_SOURCE_DIR}/Thirdparty/Sophus
)

add_library(${PROJECT_NAME} SHARED
  src/System.cc
  src/Tracking.cc
  src/Localoptim.cc
  src/Converter.cc
  src/KeyPoseFrame.cc
  src/Atlas.cc
  src/Map.cc
  src/MapDrawer.cc
  src/Optimizer.cc
  src/PoseFrame.cc
  src/Viewer.cc
  src/ImuTypes.cc
  src/G2oTypes.cc
  src/Settings.cc
  src/WheelOdom.cc
  src/State.cc
  include/System.h
  include/Tracking.h
  include/Localoptim.h
  include/Converter.h
  include/KeyPoseFrame.h
  include/Atlas.h
  include/Map.h
  include/MapDrawer.h
  include/Optimizer.h
  include/PoseFrame.h
  include/Viewer.h
  include/ImuTypes.h
  include/G2oTypes.h
  include/Settings.h
  include/Filter/ESKF.h
  include/Filter/WheelOdom.h
  include/Filter/State.h
)

add_subdirectory(Thirdparty/g2o)

target_link_libraries(${PROJECT_NAME}
  ${OpenCV_LIBS} 
  ${EIGEN3_LIBS}
  ${Pangolin_LIBRARIES}
  ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
  ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
  -lboost_system
  -lcrypto
)

# Build examples
add_executable(imu_odom src/imu_odom_fusion.cpp)
target_link_libraries(imu_odom ${catkin_LIBRARIES} ${PROJECT_NAME})
add_dependencies(imu_odom ${PROJECT_NAME}_generate_messages_cpp)
